<?php 
//namespace app\modules\admin\models\views\view;
/*
$h=new \app\commands\HelloController("ddd", "");
$h->actionIndex();
*/
//use Yii;
use app\models\Jilu; 
use app\models\Log;

$mulu = Yii::getAlias("@app");
require_once($mulu . '/components/Excel/PHPExcel.php');



$resultPHPExcel = new \PHPExcel();
$jilu = new \app\modules\admin\models\ViewJilu();
$list = Jilu::find()->all();
$jilu->showEcho = false;
$topList = [];
$lab = $jilu->ExceLabels();

$tl = 0;
foreach ($lab as $key => $vo) {
    $zm = $jilu->get_char($tl, 0);
    $resultPHPExcel->getActiveSheet()->setCellValue($zm . '1', $vo);
    $tl++;
    $topList[$key] = $zm;
}

$length = count($list); 
$hang = 2;
foreach ($list as $vo) {
    foreach ($topList as $key => $lie) {
        $val = $jilu->ModelTohtml($key, $vo);
        $resultPHPExcel->getActiveSheet()->setCellValue($lie . $hang, $val);
    }
    $hang++;
    $wc = (int) (($hang - 2) / $length * 100);
}
///var_dump($hang);exit;
$xlsWriter = new \PHPExcel_Writer_Excel5($resultPHPExcel);
 
$outputFileName = $jilu->getName() . '.xls';
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="' . $outputFileName . '"');
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");

$xlsWriter->save("php://output");
 

exit;




